<?php

abstract class App_Session_Abstract
{
    /**
     * Session namespace
     * 
     * @var string
     */
    protected $_namespace = null;
    
    /**
     * Persistent storage handler
     *
     * @var Zend_Session_Namespace
     */
    protected $_storage = null;
    
    /**
     * Get session namespace
     *
     * @return Zend_Session_Namespace
     */
    protected function _getStorage()
    {
        if (null === $this->_storage) {
            $this->_setStorage(new Zend_Session_Namespace($this->_namespace));
        }
        return $this->_storage;
    }

    /**
     * Set session namespace
     *
     * @param  Zend_Session_Namespace $storage
     * 
     * @return void
     */
    protected function _setStorage(Zend_Session_Namespace $storage)
    {
        $this->_storage = $storage;
    }

    /**
     * Clear session object
     *
     * @return void
     */
    public function clear()
    {
        $this->_storage === null;
    }
    
    /**
     * Destroy session
     * 
     * @return void
     */
    public function destroy()
    {
        session_destroy();
    }
    
    /**
     * Defined by Zend_Auth_Storage_Interface
     *
     * @return boolean
     */
    public function isEmpty()
    {
        return !isset($this->_session->{$this->_member});
    }
}